package thread;

import java.util.concurrent.atomic.AtomicInteger;

public class ThreadDemo37 {
    public static volatile AtomicInteger atomicInteger = new AtomicInteger();
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() ->{
            for(int i = 1 ; i <= 5000; i++){
                atomicInteger.incrementAndGet();
            }
        });
        Thread t2 = new Thread(() ->{
           for(int i = 1; i <= 5000; i++){
               atomicInteger.incrementAndGet();
           }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(atomicInteger);
    }
}
